package com.tac.controller;

import com.tac.common.result.Result;
import com.tac.common.util.ImgUtis;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/img")
@Api(value = "上传图片",tags ="上传图片" )
public class ImgCtroller {
    @Value("${shopping.path}")
    private  String baserl;
    /**
     * 上传图片
     * @param
     * @return
     */
    @ResponseStatus(HttpStatus.CREATED)
    @ApiOperation("上传图片")
    @PostMapping
    public Result<String>  upload(List<MultipartFile> files) throws IOException {
        String saveimg = ImgUtis.saveimgs(files,baserl);
      return   Result.success(saveimg,"success");
    }


}
